
import { HTTP } from './request'
import { message } from 'antd'
import dynamic from './dynamic'
import Redirect from './redirect'
import axios from 'axios';

export { HTTP,dynamic,Redirect }

export function getStorageItem<T>(key: string, storageType: 'localStorage' | 'sessionStorage', defaultData: T): T {
  const itemData = window[storageType].getItem(key)
  if (!itemData) {
    return defaultData
  }
  return JSON.parse(itemData)
}

export function flatRouter(routers: any[]) {
  return routers
    .map((item: any) => {
      if (item.element && !item.children) {
        return item
      }
      return item.children.map((k: any) => {
        return k
      })
    })
    .flat(1)
}